const sequelize = require("../config/database")

// 导入模型
const Building = require("./building")
const Unit = require("./unit")
const Household = require("./household")
const PropertyStaff = require("./propertyStaff")
const OutsourceStaff = require("./outsourceStaff")

// 定义模型关联关系
Building.hasMany(Unit, { foreignKey: "building_id" })
Unit.belongsTo(Building, { foreignKey: "building_id" })

Unit.hasMany(Household, { foreignKey: "unit_id" })
Household.belongsTo(Unit, { foreignKey: "unit_id" })

module.exports = {
  sequelize,
  Building,
  Unit,
  Household,
  PropertyStaff,
  OutsourceStaff,
}
